package org.example.mock;

import lombok.extern.slf4j.Slf4j;
import org.example.bean.MovieTypes;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 用于生成 MovieTypes 模拟数据的工具类，
 * 适配 movie_types 表结构，可生成指定数量模拟电影类型数据
 */
@Slf4j
public class MovieTypeGenerator {
    private static final String DB_URL = "jdbc:mysql://hadoop2/changchenfilm?useSSL=false&requireSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC";
    private static final String DB_USER = "root";
    private static final String DB_PASSWORD = "000000";
    private static final int BATCH_SIZE = 100;
    // 存储生成的模拟数据列表，按需使用
    private static final List<MovieTypes> DATA_LIST = new ArrayList<>();
    private static final Random RANDOM = new Random();
    // 模拟的类型ID起始值，可根据实际场景调整
    private static int currentTypeId = 1;
    // 预设的类型名称列表，可根据实际需求扩充
    private static final String[] TYPE_NAMES = {"动作", "喜剧", "科幻", "悬疑", "爱情", "动画", "惊悚", "剧情", "冒险", "犯罪"};

    public static void main(String[] args) {
        log.info("开始生成 MovieTypes 模拟数据");
        List<MovieTypes> result = generateData(10);
        log.info("生成完成，模拟数据如下：");
        result.forEach(data -> log.info(data.toString()));
    }

    /**
     * 生成指定数量的 MovieTypes 模拟数据
     * @param count 要生成的数据条数
     * @return 包含模拟数据的 List<MovieTypes>
     */
    private static List<MovieTypes> generateData(int count) {
        List<MovieTypes> dataList = new ArrayList<>();
        for (int i = 0; i < count; i++) {
            MovieTypes data = new MovieTypes();
            data.setTypeId(currentTypeId++);
            // 从预设类型名称列表中选取，超出则自定义（也可全随机生成）
            if (i < TYPE_NAMES.length) {
                data.setTypeName(TYPE_NAMES[i]);
            } else {
                data.setTypeName("自定义类型_" + (i + 1));
            }

            dataList.add(data);
            DATA_LIST.add(data);
        }
        return dataList;
    }
}